<template>
    <div>
      <div class="header_search_nav search_form">
        <div class="ipt_left">
          <el-form ref="queryForm" :model="queryParams" label-width="80px">
            <el-row>
              <el-col :span="6">
                <el-form-item label="区域" prop="districtId">
                  <el-select
                    v-model="queryParams.districtId"
                    placeholder="请选择"
                    clearable
                    filterable
                    @change="handleQuery"
                  >
                    <el-option
                      v-for="item in AreaData"
                      :key="item.districtId"
                      :label="item.districtName"
                      :value="item.districtId"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
  
              <el-col :span="6">
                <el-form-item label="门店" prop="storeId">
                  <el-select
                    v-model="queryParams.storeId"
                    placeholder="请选择"
                    filterable
                    clearable
                    @change="handleQuery"
                  >
                    <el-option
                      v-for="(item, index) in $store.state.user.stores"
                      :key="index"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
  
              <el-col :span="6">
                <div class="timebox">
                  <el-form-item label="日期时间" prop="moon">
                    <el-date-picker
                      v-model="queryParams.moon"
                      type="month"
                      placeholder="选择月"
                      value-format="yyyy-MM"
                    >
                    </el-date-picker>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
          </el-form>
        </div>
  
        <div class="btn_right">
          <button class="btn1" @click="handleQuery">筛选</button>
          <button class="btn2" @click="resetQuery">重置</button>
        </div>
      </div>
  
      <div class="table_card">
        <!-- 上部分 title -->
        <div class="table_card_top">
          <span class="solid_left1"></span>
          <div class="table_card_title">业务数据分析12121</div>
          <!-- v-hasPermi="['order:finance:store:revenue:exl']" -->
          <div class="op_right">
            <el-button
              @click="handleExport"
              :loading="exportLoading"
              class="repeat"
              >导出</el-button
            >
          </div>
        </div>
  
        <div class="table_list">
          <div class="tableBox">
            <el-table :data="storeTaskData">
              <el-table-column
                prop="districtName"
                label="区域"
                align="center"
                width="200"
              >
              </el-table-column>
              <el-table-column
                prop="storeName"
                label="门店"
                align="center"
                width="200"
              >
              </el-table-column>
              <el-table-column
                prop="storeMoneyTask"
                label="本月任务"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="nowStoreMoney"
                label="本月业绩"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="upStoreMoney"
                label="上月业绩"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="sumInCardMoney"
                label="总充卡"
                align="center"
              >
              </el-table-column>
              <el-table-column prop="subCardMoney" label="总销卡" align="center">
              </el-table-column>
              <el-table-column prop="custCount" label="总客量" align="center">
              </el-table-column>
              <el-table-column prop="addCount" label="加钟数" align="center">
              </el-table-column>
              <el-table-column prop="pointCount" label="点钟数" align="center">
              </el-table-column>
              <el-table-column
                prop="inCardCount"
                label="充卡总张数"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="visitorCount"
                label="约客数量"
                align="center"
              >
              </el-table-column>
            </el-table>
          </div>
        </div>
      </div>
    </div>
  </template>
        
  <script>
  import { getBusinessCountExport } from "@/api/bpm/excle";
  import { getBusinessCount } from "@/api/bpm/reports";
  import { getManagerDistrict } from "@/api/bpm/commission";
  import { dayDataTime } from "@/utils/utils";
  import timer from "@/components/getTime/timer";
  export default {
    name: "Eryuoastoreregionalreports",
    components: { timer },
    data() {
      return {
        loading: false,
        exportLoading: false,
        saveLoading: false,
        value: "",
        // dialogVisible: false,
        // 查询参数
        queryParams: {
          pageNo: 1,
          pageSize: 10,
          storeId: "",
          moon: "",
          districtId:'',
        },
  
        AreaData: [], // 区域数据
        total: 0,
        storeTaskData: [],
      };
    },
  
    mounted() {},
  
    created() {
      let date = dayDataTime("obj");
      this.queryParams.moon = date.y + "-" + date.m;
      this.getList();
  
      this.getAreaData();
    },
  
    methods: {
      // 获取区域数据
      getAreaData() {
        getManagerDistrict(this.queryParams)
          .then((res) => {
            const { code, data } = res;
            if (code === 0) {
              this.AreaData = data;
            }
          })
          .catch((err) => {
            this.loading = false;
          });
      },
  
      HandleClose() {
        this.resetFormData("ruleForm");
        this.$nextTick(() => {
          this.dialogVisible = false;
        });
      },
  
      handleExport() {
        this.$modal
          .confirm("是否确认导出报表数据?")
          .then(() => {
            this.exportLoading = true;
            return getBusinessCountExport(this.queryParams);
          })
          .then((response) => {
            this.$download.excel(response, "业务数据分析");
            this.exportLoading = false;
          })
          .catch(() => {
            this.exportLoading = false;
          });
      },
  
      // 筛选
      handleQuery() {
        // this.queryParams.pageNo = 1;
        this.getList();
      },
  
      /** 重置按钮操作 */
      resetQuery() {
        this.resetFormData("queryForm");
        // this.queryParams.localDate = dayDataTime("obj").str;
        this.handleQuery();
      },
  
      // 表单重置
      resetFormData(formName) {
        console.log(this.$refs[formName]);
        this.$nextTick(() => {
          this.$refs[formName].resetFields();
        });
      },
  
      // 业务数据分析
      getList() {
        // console.log(this.queryParams);
        this.loading = true;
  
        if (!this.queryParams.moon) {
          this.$message.error("日期时间不能为空");
          return false;
        }
  
        getBusinessCount(this.queryParams)
          .then((res) => {
            console.log(res);
            this.loading = false;
            const { code, data } = res;
            if (code === 0) {
              this.storeTaskData = data;
            }
          })
          .catch((err) => {
            this.loading = false;
          });
      },
    },
  };
  </script>
        
        <style lang="scss" scoped>
  .solid_left1 {
    margin-left: 24px;
  }
  .goodTop {
    width: 100%;
    height: 48px;
    background: #ffffff;
    display: flex;
    font-size: 14px;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.6);
    line-height: 48px;
    padding-left: 16px;
    .good_list {
      margin-right: 32px;
    }
  
    .good_active {
      color: #0052d9;
      border-bottom: 1px solid #0052d9;
    }
  }
  
  .w-200 {
    width: 200px;
    background: #ffffff;
    border-radius: 4px;
  }
  
  .client_name {
    font-size: 14px;
    font-weight: 400;
    color: #0052d9;
  }
  
  .give {
    height: 40px;
    font-size: 14px;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.85);
    margin-top: 40px;
    line-height: 40px;
  }
  
  .el-form-item {
    margin-bottom: 20px;
  }
  
  .recharge_form {
    padding: 10px 24px;
  }
  
  .memberName {
    font-size: 14px;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.85);
  }
  .el_row_item {
    margin-bottom: 10px;
  }
  .el_row_date {
    margin-top: 20px;
  }
  .el_row_reason {
    margin-top: 10px;
  }
  
  .el_row_date {
    .el-form-item {
      margin-bottom: 0px;
    }
  }
  
  .Order_box {
    display: flex;
    margin-left: -50px;
    .select_ipt {
      width: 130px;
      margin-right: 10px;
    }
  }
  
  .pay_ipt {
    margin-left: 50px;
  }
  
  .order_ipt {
    margin-left: -120px;
  }
  
  .timebox {
    margin-top: 10px;
  }
  
  .table_list {
    position: relative;
    padding-right: 30px;
    padding-bottom: 24px;
  
    .red {
      color: red;
    }
  }
  </style>
        